package com.guli.mall.wms.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.ApiOperation;

import com.guli.mall.wms.entity.WareInfoEntity;
import com.guli.mall.wms.service.WareInfoService;
import com.guli.common.utils.PageUtils;
import com.guli.common.utils.R;


/**
 * 仓库信息
 *
 * @author 罗俊华
 * @email 1007052116@qq.com
 * @date 2020-09-29 21:37:28
 */
@RestController
@RequestMapping("wms/wareinfo")
public class WareInfoController {
    @Autowired
    private WareInfoService wareInfoService;


    @GetMapping("/list/{currentPage}/{size}")
    @ApiOperation("根据当前页和每页显示的记录数来获取wareInfo分页列表")
    public R list(@PathVariable("currentPage") Integer currentPage, @PathVariable("size") Integer size,
                  @RequestParam Map<String, String> params) {
        PageUtils<WareInfoEntity> page = wareInfoService.queryPage(currentPage, size,params);

        return R.ok().put("page", page);
    }


    @GetMapping("/info/{id}")
    @ApiOperation("根据id获取WareInfo")
    public R info(@PathVariable("id") Long id) {
        WareInfoEntity wareInfo = wareInfoService.getById(id);

        return R.ok().put("wareInfo", wareInfo);
    }

    @PostMapping("/save")
    @ApiOperation("插入WareInfo")
    public R save(@RequestBody WareInfoEntity wareInfo) {
        wareInfoService.save(wareInfo);

        return R.ok();
    }

    @PostMapping("/update")
    @ApiOperation("根据id更新WareInfo")
    public R update(@RequestBody WareInfoEntity wareInfo) {
        wareInfoService.updateById(wareInfo);

        return R.ok();
    }

    @PutMapping("/deleteBatch")
    @ApiOperation("根据id批量删除WareInfo")
    public R delete(@RequestBody Long[] ids) {
        wareInfoService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
